package com.example.epic.bean.mq;

import com.alibaba.fastjson.JSON;
import com.example.epic.bean.InAndOutRecord;
import com.example.epic.service.InAndOutRecordService;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class MqReceiver {

    @Autowired
    InAndOutRecordService inAndOutRecordService;

    @RabbitListener(queues = "inOutRecordQueue")
    @RabbitHandler
    public void receiveInOutRecord(String msg){
        InAndOutRecord inAndOutRecord = JSON.toJavaObject(JSON.parseObject(msg), InAndOutRecord.class);
//        inAndOutRecordService.savaInAndOutRecord(inAndOutRecord);
        System.out.println("inAndOutRecord = " + inAndOutRecord);
    }
}
